
const vscode = acquireVsCodeApi();  // 获取vscode模块
let dom = document.getElementById('export');
let select = document.getElementById('select');
let textarea = document.getElementById('textarea');

dom.innerHTML = `ready`;
function handleClick() {
  // 调用命令
  console.log(vscode);
  if (vscode) {
    vscode.postMessage({
      cmd: select.value || null,
      text: '你好，我是Webview啊！',
      params: select.value == 'genFile' ? textarea.value : ''
    });
  } else {
    dom.innerHTML += `<br />没有vscode模块`;
  }
};

window.addEventListener('message', event => {
  const message = event.data;
  console.log('Webview接收到的消息：', message);
  dom.innerHTML += `<br />${message}`;
});